import request from '@/utils/request'

// 查询维护单列表
export function listActMaintainOrder(query) {
  return request({
    url: '/activiti/actMaintainOrder/list',
    method: 'get',
    params: query
  })
}

// 查询维护单列表
export function test_mock(query) {
  return request({
    url: '/user/info',
    method: 'get',
    params: query
  })
}

//保存表单数据
export function createProcessInstance(data){
  return request({
    url: '/activiti/actMaintainOrderData/saveFormData',
    method: 'post',
    data: data
  })
}

// 查询维护单详细
export function getActMaintainOrder(id) {
  return request({
    url: '/activiti/actMaintainOrder/' + id,
    method: 'get'
  })
}

// 新增维护单
export function addActMaintainOrder(data) {
  return request({
    url: '/activiti/actMaintainOrder',
    method: 'post',
    data: data
  })
}

// 修改维护单
export function updateActMaintainOrder(data) {
  return request({
    url: '/activiti/actMaintainOrder',
    method: 'put',
    data: data
  })
}

// 删除维护单
export function delActMaintainOrder(id) {
  return request({
    url: '/activiti/actMaintainOrder/' + id,
    method: 'delete'
  })
}

/**
 * 将服务端返回的 fields 字符串数组，解析成 JSON 数组
 *
 * @param fields JSON 字符串数组
 * @returns {*[]} JSON 数组
 */
export function decodeFields(fields) {
  const drawingList = []
  fields.forEach(item => {
    drawingList.push(JSON.parse(item))
  })
  return drawingList
}
